package com.awesome.spring.es.Controller;

import com.awesome.spring.es.entity.ContentsIndex;
import com.awesome.spring.es.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @program: awesome-spring
 * @description:
 * @author: Alex Wu
 * @createDate: 2025-03-03 16:02
 **/

@RestController
@RequestMapping("/es")
public class ESController {

    @Autowired
    private ContentService contentService;

    @GetMapping("")
    public Boolean saveValue() {
        ContentsIndex contentsIndex = new ContentsIndex();
        contentsIndex.setId(123);
        contentsIndex.setTitle("Spring Boot");
        contentsIndex.setIntro("intro");
        contentsIndex.setContent("Spring Boot Elasticsearch");
        contentsIndex.setCreateTime(new Date());
        contentService.save(contentsIndex);
        return true;
    }

}
